package day20171221;

import com.sun.activation.registries.MailcapParseException;
import com.sun.javafx.collections.MappingChange;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by lady on 2017/12/21.
 */
public class Test {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        String stuNo = "";
        //字符流方式
        String path = "F:\\大二上学期\\Java\\期末大作业\\data\\names.txt";
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(path));

            while ((stuNo = reader.readLine()) != null) {
                map.put(stuNo, 0);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
//获取文件夹下所有文件
        File file = new File("F:\\大二上学期\\Java\\期末大作业\\data\\16信本2班Java作业一");
        File[] files = file.listFiles();
        //遍历
for (File f:files) {
    String fileName=f.getName();
    //保存提取学号
            String no ="";

    //从文件中提取学号
    //正则表达式;1、模板； 2、三个填空
    Matcher matcher = Pattern.compile("信本2班（\\d+）").matcher(fileName);
    while(matcher.find()){
        no=matcher.group(1);
    }
map.put(no,1);
        }

       //把value为零的打印出来
        //遍历一个map
        for(Map.Entry<String,Integer> entry:map.entrySet()){
    if(entry.getValue()==0){

        System.out.println(entry.getKey());
    }

        }
    }
}